export type ContestRuleType = 'ACM' | 'OI';

export type ContestStatus = '1' | '0' | '-1'; // 1: 未开始, 0: 进行中, -1: 已结束

export type ContestType = 'Public' | 'Password Protected'; // 0: 公开比赛, 1: 密码保护比赛

export interface Contest {
  id: number;
  title: string;
  description?: string;
  start_time: string;
  end_time: string;
  created_by: {
    id: number;
    username: string;
  };
  rule_type: ContestRuleType;
  password?: string;
  real_time_rank: boolean;
  status: ContestStatus;
  contest_type: ContestType;
  visible: boolean;
  allowed_ip_ranges?: string[];
}

export interface ContestListParams {
  keyword?: string;
  rule_type?: ContestRuleType;
  status?: ContestStatus;
}

export interface VerifyPasswordParams {
  password: string;
}

export interface Announcement {
  id: number;
  title: string;
  content: string;
  contest: number;
  created_by: {
    id: number;
    username: string;
  };
  visible: boolean;
  create_time: string;
}

export interface AnnouncementListParams {
  contest_id?: number;
  keyword?: string;
}

export interface ContestParticipant {
  id: number;
  user_info: {
    id: number;
    username: string;
  };
  join_time: string;
}

export interface ContestParticipantListParams {
  contest_id: number;
}

// 排行榜项目类型
export interface ContestRankingItem {
  id: number;
  user: {
    id: number;
    username: string;
    email: string;
    admin_type: string;
    last_login: string;
  };
  profile: {
    id: number;
    username: string;
    email: string;
    admin_type: string;
    avatar: string;
    real_name: string | null;
    blog: string | null;
    mood: string | null;
    github: string | null;
    school: string | null;
    major: string | null;
    language: string | null;
    submission_number: number;
    accepted_number: number;
  };
  submission_number: number;
  total_score: number;
  accepted_number?: number; // ACM赛制使用
  total_time?: number; // ACM赛制使用
  submission_info: {
    [problemId: string]: number; // 题目ID -> 分数
  };
  contest: number;
}

// 获取排行榜参数
export interface ContestRankingParams {
  contest_id: number;
  page?: number;
  limit?: number;
}

// 批阅相关类型定义
export interface ContestSubmission {
  id: string;
  create_time: string;
  result: number;
  language: string;
  statistic_info: {
    time_cost?: number;
    memory_cost?: number;
    score?: number;
  };
  code: string;
}

export interface ContestProblem {
  problem_id: number;
  problem_title: string;
  submissions: ContestSubmission[];
}

export interface ContestUserSubmission {
  user_id: number;
  username: string;
  real_name: string;
  submission_number: number;
  total_score: number;
  accepted_number: number;
  total_time: number;
  problems: ContestProblem[];
}

export interface ContestSubmissionResponse {
  count: number;
  next: string | null;
  previous: string | null;
  results: ContestUserSubmission[];
} 